import request from '@/utils/request'
import config from '@/config'
import {getToken} from '@/utils/auth'
// 登录方法 api/user/login
export function login(code) {
    return request({
        url: '/weixin_mini_app/login',
        method: 'post',
        data: {username:code}
    })
}
//pages/login/index /common/store_manager/qrcode

export function qrcode() {
  return request({
      url: '/common/store_manager/qrcode',
      method: 'get',
  })
}

export function uploadFile(avatarUrl, name) {
    return new Promise((resolve, reject) => {
      wx.uploadFile({
        url: config.baseUrl +"/common/upload", //服务器地址
        filePath: avatarUrl, //文件临时路径
        name: "file",
        header: {
          Authorization: getToken(),
          "Content-Type": "multipart/form-data",
        },
        formData: {
          file: avatarUrl,
        },
        success: (res) => {
          console.log(res, "asdasdas");
          resolve(res.data)
        },
        fail: (error) => {
          // uni.hideLoading();
          // console.log(error);
        },
      });
    });
  }
